/* Copyright (c) 2012 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.gdata.aeuploader;


import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * The Class FileBlobProvider.
 */
public class FileBlobProvider implements BlobProvider {

  /** The file. */
  private File file;
  
  /**
   * Instantiates a new file blob provider.
   *
   * @param filename the filename
   */
  public FileBlobProvider(String filename) {
    file = new File(filename);
  }
  
  /* (non-Javadoc)
   * @see com.google.gdata.aeuploader.BlobProvider#getSize()
   */
  @Override
  public long getSize() {
    // TODO Auto-generated method stub
    return file.length();
  }

  /* (non-Javadoc)
   * @see com.google.gdata.aeuploader.BlobProvider#getStream()
   */
  @Override
  public InputStream getStream() {
    // TODO Auto-generated method stub
    try {
      return new FileInputStream(file);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return null;
    }
  }

  /* (non-Javadoc)
   * @see com.google.gdata.aeuploader.BlobProvider#getType()
   */
  @Override
  public String getType() {
    // TODO Auto-generated method stub
    return "application/pdf";
  }

}
